package week3;

import java.util.Arrays;
import java.util.Scanner;




public class Main6 {
    private static Scanner in;
    public static void main(String[] args) {
        in=new Scanner(System.in 

);
        boolean k=true;
        int n1,n2,e=0;
        String name;
        int age;
        boolean gender;
        while (true){
            e=0;
            n1=in.nextInt();
            PersonOverride[] persons1=new PersonOverride[n1];
            for (int i = 0; i < n1; i++) {
                persons1[i]=new PersonOverride();
            }

            n2=in.nextInt();
            PersonOverride[] persons2=new PersonOverride[n2];
            for (int i = 0; i <n2 ; i++) {
                k=true;
                if (e==0)
                {
                    persons2[e]=new PersonOverride(in.next(),in.nextInt(),in.nextBoolean());
                    e++;
                }
                else
                {
                    name=in.next();
                    age=in.nextInt();
                    gender=in.nextBoolean();
                    for (int j = 0; j < e; j++) {

                        if (persons2[j].equals(name,age,gender))
                          k=false;

                    }
                    if (k==true)
                    {
                        persons2[e]=new PersonOverride(name,age,gender);
                        e++;
                    }
                }

            }
            for (int i = 0; i < n1; i++) {
                System.out.println(persons1[i].toString());
            }
            for (int i = 0; i < e; i++) {
                System.out.println(persons2[i].toString());
            }
            System.out.println(e);
            System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));


        }



    }


}


class PersonOverride{
    private String name;
    private boolean gender;
    private int age;

    public PersonOverride() {

        this("default", 1,true);

    }
  public PersonOverride(String name,int age,boolean gender) {
        this.name 

 = name;
        this.age=age;
        this.gender=gender;
    }
    @Override
    public String toString() {
        return name + "-" + age + "-" +  gender;
    }


    public boolean equals(String name,int age,boolean gender) {
       return name.equals(this.name 

)&&(age==this.age)&&(gender==this.gender);
    }

}